package com.heima.admin.service.impl;

import com.heima.admin.service.ChannelService;
import com.heima.apis.wemedia.IWemediaClient;
import com.heima.model.admin.dtos.ChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import com.heima.model.wemedia.pojos.WmChannel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
@Slf4j
public class ChannelServiceImpl implements ChannelService {

    @Autowired
    private IWemediaClient iWemediaClient;
    /**
     * 删除频道
     *
     * @param id
     * @return
     */
    @Override
    public ResponseResult delChannel(Integer id) {
        if(null==id){
            return ResponseResult.errorResult(AppHttpCodeEnum.PARAM_INVALID);
        }
        return iWemediaClient.delChannel(id);
    }

    /**
     * 查询频道列表
     *
     * @param dto
     * @return
     */
    @Override
    public ResponseResult listChannel(ChannelDto dto) {
        return iWemediaClient.listChannel(dto);
    }

    /**
     * 保存频道信息
     *
     * @param dto
     * @return
     */
    @Override
    public ResponseResult saveChannel(WmChannel dto) {
        return iWemediaClient.saveChannel(dto);
    }

    /**
     * 更新频道信息
     *
     * @param dto
     * @return
     */
    @Override
    public ResponseResult updateChannel(WmChannel dto) {
        return iWemediaClient.updateChannel(dto);
    }
}
